package com.bbs.manage.controller;

import com.bbs.common.CommonCode;
import com.bbs.common.ResponseResult;
import com.bbs.domain.Article;
import com.bbs.domain.Report;
import com.bbs.service.ArticleService;
import com.bbs.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName ReportController
 * @Description TODO
 * @Author cy
 * @Date 2019/9/21 18:16
 * @Version 1.0
 **/

@RestController
@RequestMapping("/report")
public class ReportController {

    @Autowired
    private ReportService reportService;

    @Autowired
    private ArticleService articleService;

    /**
     * 查询所有的被举报帖子
     * @return
     */
    @GetMapping("/findAllReport")
    public List<Report> findAllReport () {

       return reportService.findAllReport();
    }

    /**
     * 根据report表中的id查询article
     */
    @GetMapping("/findOneArticle")
    public Article findOneArticle(Report report) {

        return articleService.findOne(report);
    }

    /**
     * 屏蔽
     */
    @GetMapping("/shield")
    public ResponseResult shield (Report report) {

        reportService.shield(report);

        return new ResponseResult(CommonCode.SUCCESS);
    }

    /**
     * 驳回
     */
    @GetMapping("/reject")
    public ResponseResult reject (Report report) {

        reportService.reject(report);

        return new ResponseResult(CommonCode.SUCCESS);
    }

    /**
     * 修改举报的处理状态
     *
     * @param report
     * @return
     */
    @GetMapping("/updateReportStatus")
    public ResponseResult updateReportStatus(@RequestBody Report report) {

        reportService.updateReportStatus(report);
        return new ResponseResult(CommonCode.SUCCESS);
    }



}
